// comm/pay/index.js
const App = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    ispay: {
      type: Boolean
    },
    order: {
      type: Object
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    _closeFun () {
      this.triggerEvent('closepay');
    },
    _goRecharge () {
      console.log('立即支付', this.data.order)
      if (this.data.order.user.balance < this.data.order.total) {
        wx.navigateTo({
          url: '/pages/recharge/index',
        })
        return false;
      }
      let url = 'mp/order/pay/' + this.data.order.id;
      App.ajax(url, 'POST', '').then(res => {
        if (res.status === 10000) {
          App.prompts('删除成功');
          this.triggerEvent('upgetlist');
        }
      }).cath(err => {
        console.log(err)
      })
    }
  }
})
